<template xmlns="http://www.w3.org/1999/html">
  <div>
  <!--  <div>-->

  <!--    <div style="float: left; padding-left: 2px">-->
  <!--      <el-card class="mainpart1" shadow="hover">-->
  <!--        <div ref="chartPart1" style="width: 390px; height:380px;"></div>-->
  <!--      </el-card>-->
  <!--    </div>-->

  <!--    <div style="float: left; padding-left: 7px">-->
  <!--      <el-card class="mainpart1" shadow="hover">-->
  <!--        <div ref="chartPart2" style="width: 390px; height:380px;"></div>-->
  <!--      </el-card>-->
  <!--    </div>-->

  <!--    <div style="float: left;  padding-left: 7px">-->
  <!--      <el-card class="mainpart1" shadow="hover" style="width: 400px">-->
  <!--        <div ref="chartPart3" style="width: 390px; height:380px;"></div>-->
  <!--      </el-card>-->
  <!--    </div>-->

  <!--  </div>-->
  <el-row :gutter="10" class="panel-group" s>
    <el-col :xs="12" :sm="12" :lg="6" class="card-panel-col">
      <div class="card-panel" @click="handleSetLineChartData('newVisitis')">

        <div class="card-panel-icon-wrapper icon-all" @click="setpiedata(1)">
          <svg-icon icon-class="visit" class-name="card-panel-icon"/>
        </div>

        <div class="card-panel-description">
          <div class="card-panel-text">
            用户
          </div>
          <count-to :start-val="0" :end-val="102400" :duration="2600" class="card-panel-num"/>
        </div>
      </div>
    </el-col>

    <el-col :xs="12" :sm="12" :lg="6" class="card-panel-col">
      <div class="card-panel" @click="handleSetLineChartData('messages')">
        <div class="card-panel-icon-wrapper icon-all" @click="setpiedata(2)">
          <svg-icon icon-class="message" class-name="card-panel-icon"/>
        </div>
        <div class="card-panel-description">
          <div class="card-panel-text">
            文章
          </div>
          <count-to :start-val="0" :end-val="81212" :duration="3000" class="card-panel-num"/>
        </div>
      </div>
    </el-col>
    <el-col :xs="12" :sm="12" :lg="6" class="card-panel-col">
      <div class="card-panel" @click="handleSetLineChartData('purchases')">
        <div class="card-panel-icon-wrapper icon-all" @click="setpiedata(3)">
          <svg-icon icon-class="money" class-name="card-panel-icon"/>
        </div>
        <div class="card-panel-description">
          <div class="card-panel-text">
            销售额
          </div>
          <count-to :start-val="0" :end-val="9280" :duration="3200" class="card-panel-num"/>
        </div>
      </div>
    </el-col>
    <el-col :xs="12" :sm="12" :lg="6" class="card-panel-col">
      <div class="card-panel" @click="handleSetLineChartData('shoppings')">
        <div class="card-panel-icon-wrapper icon-all" @click="setpiedata(4)">
          <svg-icon icon-class="shopping" class-name="card-panel-icon"/>
        </div>
        <div class="card-panel-description">
          <div class="card-panel-text">
            销量
          </div>
          <count-to :start-val="0" :end-val="13600" :duration="3600" class="card-panel-num"/>
        </div>
      </div>
    </el-col>
  </el-row>

    <el-tabs type="border-card" v-model = "PageName" @tab-click="thisPage">
<!--      <el-tab-pane>
        <span slot="label"><i class="el-icon-date"></i> 我的行程</span>
        我的行程
      </el-tab-pane>-->


<!--      <el-tab-pane label="销量折线图"><div style="width: 800px ;height: 500px"></div></el-tab-pane>-->


      <el-tab-pane label="近年销量图" name="race">
        <div style="width: 800px ;height: 500px;margin: 0px;"v-if="PageName==='race'">
        <RaceChart style="display: flex;" :key="new Date().getTime()" />
      </div></el-tab-pane>
      <el-tab-pane label="数据饼图" name="pie"><div style="width: 800px ;height: 500px;margin: auto;" >
        <PieChart v-if="PageName==='pie'"/>
      </div></el-tab-pane>
    </el-tabs>
    <div style="height: 100px"></div>
  </div>
</template>

<script>
import * as echarts from 'echarts'
import CountTo from 'vue-count-to'
import RaceChart from "@/components/RaceChart.vue";
import PieChart from "@/components/PieChart.vue"

export default {
  name: "Index",
  components: {
    RaceChart,
    CountTo,
    PieChart
  },
  data() {
    return {
      PageName:'race', //当前表格界面名字
      piedata:1,
      /*tableIsShow: true,*/
/*      visit_d:"visit",*/
    }
  },
  // mounted: function () {
  //   const chart1 = echarts.init(this.$refs.chartPart1)
  //   chart1.setOption(this.option)
  //   const chart2 = echarts.init(this.$refs.chartPart2)
  //   chart2.setOption(this.option)
  //   const chart3 = echarts.init(this.$refs.chartPart3)
  //   chart3.setOption(this.option)
  // }
  methods: {
    handleSetLineChartData(type) {
      this.$emit('handleSetLineChartData', type)
    },
    thisPage(){
      console.log(this.PageName)
    },
    setpiedata(a){
      this.piedata = a
    }
    /*,
    mousehover(x) {
      this.visit_d = "visit-h"
    },
    mouseout(x){
      this.visit_d = "visit"
    }*/
  },
  /*watch:{
    'search.condition.enteringStatus': {
      handler (value) {
        this.tableIsShow = false
        setTimeout(() => {
          this.tableIsShow = true
        }, 0)
      }
    }
  }*/
}


</script>

<style scoped>

.panel-group {
  margin-top: 18px;

.card-panel-col {
  margin-bottom: 32px;
}



.card-panel {
  height: 108px;
  cursor: pointer;
  font-size: 12px;
  position: relative;
  overflow: hidden;
  color: #666;
  background: #fff;
  box-shadow: 4px 4px 40px rgba(0, 0, 0, .05);
  border-color: rgba(0, 0, 0, .05);


.icon-all {
  color: #34bfa3;
}
.icon-all:hover{
  color: #ffffff;
  background: #34bfa3;
}

.card-panel-icon-wrapper {
  float: left;
  margin: 0px 0px 0px 30px;
  padding: 16px 16px 16px 16px ;
  transition: all 0.5s ease-out; /*悬停变色时候减速更顺滑*/
  border-radius: 6px;
}

.card-panel-icon {
/*  color: #ffffff;*/
  float: left;
  font-size: 48px;
}
.card-panel-icon-hover {
  color: #ffffff;
  float: left;
  font-size: 48px;
}

.card-panel-description {
  float: right;
  font-weight: bold;
  margin: 26px 60px 26px 0;
  margin-left: 0px;

.card-panel-text {
  line-height: 18px;
  color: rgba(0, 0, 0, 0.45);
  font-size: 25px;
  margin-bottom: 12px;
}

.card-panel-num {
  font-size: 20px;
}

}
}
}

@media (max-width: 550px) {
  .card-panel-description {
    display: none;
  }

  .card-panel-icon-wrapper {
    float: none !important;
    width: 100%;
    height: 100%;
    margin: 0 !important;

  .svg-icon {
    display: block;
    margin: 14px auto !important;
    float: none !important;
  }
}

}




</style>
